<template>
  <div class="cart-line">
    <router-link to="/cart" tag="a"
      ><Icon type="ios-cart-outline" style="margin-right:3px;" />购物车<span
        >[{{ cart_num }}]</span
      ></router-link
    >
  </div>
</template>

<script>
import { mapState } from "vuex";
export default {
  computed: {
    ...mapState(["cart_num", "isLogin"])
  },
  mounted() {
    if (this.$store.state.isLogin) {
      this.$store.dispatch("updateCartNum");
    }
  }
};
</script>

<style lang="scss" scoped>
.cart-line {
  padding: 5px 15%;
  background: $body_color;
  color: $color;
  border-top: 1px solid $border_color;
}
</style>
